<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="co.kr.teamcloud.issue.service.*" %>
<%@ page import="com.google.appengine.api.users.*" %>
<%@ page import="com.google.appengine.api.datastore.*" %>   
<%@ page import="com.teamcloud.member.service.MemberVO" %> 
 
<jsp:useBean id="memberVO" class="com.teamcloud.member.service.MemberVO" scope="page" />
<jsp:setProperty property="*" name="memberVO" />

<%
/*
	String mberEmailAdres = request.getParameter("mberEmailAdres");		//회원 이메일	
	String mberNm = request.getParameter("mberNm");						//회원명
	String password = request.getParameter("password");					//비밀번호
	String passwordAgain = request.getParameter("passwordAgain");		//비밀번호 확인
	*/
	
	String msg = "";
	
	if(memberVO.getMberEmailAdres()==null || "".equals(memberVO.getMberEmailAdres().trim())) {
		msg = "이메일을 입력하세요.";
	}
	else if(memberVO.getMberNm()==null || "".equals(memberVO.getMberNm().trim())) {
		msg = "회원명을 입력하세요.";
	}
	else if(memberVO.getPassword()==null || "".equals(memberVO.getPassword().trim())) {
		msg = "비밀번호를 입력하세요.";
	}
	else if(memberVO.getPassword().equals(memberVO.getPasswordAgain())==false) {
		msg = "비밀번호가 일치하지 않습니다.";
	}
	if( msg.equals("")==false ) {
		pageContext.setAttribute("memberVO", memberVO, pageContext.REQUEST_SCOPE);
		pageContext.setAttribute("msg", msg, pageContext.REQUEST_SCOPE);
		pageContext.forward("memberForm.jsp");
		//response.sendRedirect("memberForm.jsp");
		return;
	}


    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
        
    //저장할 데이터
    Key memberKey = KeyFactory.createKey("member", "member");
    Entity member = new Entity("meberId", memberKey);
    member.setProperty("mberEmailAdres", memberVO.getMberEmailAdres());			//이메일
    member.setProperty("mberNm", memberVO.getMberNm());							//사용자 명
    member.setProperty("password", memberVO.getPassword());						//비밀번호
    member.setProperty("frstRegisterId", member.getKey().getId());				//등록자 ID
    member.setProperty("frstRegistPnttm", new Date());
    member.setProperty("useAt", "Y");
    
    //데이터 저장
    datastore.put(member);
    
   	response.sendRedirect("memberList.jsp");
%>
